﻿namespace Chess.Common.Game
{
    public sealed class Piece
    {
        public PieceType PieceType { get; private set; }
        public Color Color { get; private set; }

        public Piece(PieceType pieceType, Color color)
        {
            PieceType = pieceType;
            Color = color;
        }

        public bool Equals(Piece other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.PieceType, PieceType) && Equals(other.Color, Color);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Piece)) return false;
            return Equals((Piece) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (PieceType.GetHashCode()*397) ^ Color.GetHashCode();
            }
        }
    }
}
